package olga.gorbatiuk.perdep.entity;

import java.io.Serializable;
import java.util.List;
import java.util.Objects;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Olga Gorbatiuk
 */
@XmlRootElement
public class Customer implements Serializable {

    private static final long serialVersionUID = 1L;
    private Integer customerId;
    private String name;
    private List<Project> projectList;

    public Customer(Integer customerId, String name) {
        this.customerId = customerId;
        this.name = name;
    }

    public Integer getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Integer customerId) {
        this.customerId = customerId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @XmlTransient
    public List<Project> getProjectList() {
        return projectList;
    }

    public void setProjectList(List<Project> projectList) {
        this.projectList = projectList;
    }

    @Override
    public final int hashCode() {
        return Objects.hash(this.name);
    }

    @Override
    public final boolean equals(Object object) {
        if (this == object) {
            return true;
        }
// Null check is unnecessary, because the instanceof operator is specified
// to return false if its first operand is null, regardless of what type
// appears in the second operand [JLS, 15.20.2].
        if (!(object instanceof Customer)) {
            return false;
        }
        final Customer other = (Customer) object;
        return Objects.equals(this.name, other.name);
    }

    @Override
    public String toString() {
        return "olga.gorbatiuk.perdep.entity.Customer[ customerId=" + customerId + " ]";
    }

}
